package com.general.framework.qinyi.event.listener;

import org.qinyi.event.PushEvent;
import org.qinyi.event.PushEventMessage;
import org.springframework.context.ApplicationListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * 推送事件监听器 - 第一种实现方式
 */
@Component
public class PushEventListener01 implements ApplicationListener<PushEvent>  {

    @Async("eventAsyncTaskExecutor")  // 去掉该注解，则该监听器会在Main线程中同步执行
    @Override
    public void onApplicationEvent(PushEvent event) {
        PushEventMessage message = (PushEventMessage) event.getSource();
        System.out.println("PushEventListener01 收到推送事件：" + message.getContent());
    }
}
